package com.example.tilitili.controller;

import com.example.tilitili.service.IUserService;
import com.example.tilitili.vo.LoginVo;
import com.example.tilitili.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {
    /*校验*/
    @Autowired
    private IUserService userService;
    /*页面跳转*/
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }
    /*登录功能*/
    @RequestMapping("/doLogin")
    @ResponseBody/*千万不要忘记！*/
    public RespBean doLogin(@Valid LoginVo loginVo, HttpServletRequest Request,HttpServletResponse Response) {
        return userService.doLogin(loginVo,Request,Response);
    }

}
